<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<%@ taglib prefix="f" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<form action="/article/addVote" method="post" name = "voteForm">
  
  <div class="form-group">
    <label for="exampleInputPassword1" >问题</label>
    <input type="text" class="form-control"  name = "question">
  </div>
  <div class="form-group">
    <label for="exampleInputPassword1" >选项A</label>
    <input type="text" class="form-control"  name = "options">
  </div>
  <div class="form-group">
    <label for="exampleInputPassword1" >选项B</label>
    <input type="text" class="form-control"  name = "options">
  </div>
  <div class="form-group">
    <label for="exampleInputPassword1" >选项C</label>
    <input type="text" class="form-control"  name = "options">
  </div>
  <div class="form-group">
    <label for="exampleInputPassword1" >选项D</label>
    <input type="text" class="form-control"  name = "options">
  </div>
  
  <input type="button" onclick = "subForm()" class="btn btn-primary" value = "发起投票">
</form>

	<script type="text/javascript">
		
		function subForm(){
			$.post("/article/addVote",$("form[name='voteForm']").serialize(),function(msg){
				
				if(msg.id == 0 ){
					alert("添加投票成功！");
					location = "/"
				}else{
					alert("添加投票失败！");	
				}	
			})	
		}
	
	
	
	
	</script>

